home *** CD-ROM | disk | FTP | other *** search
/ Commodore Disk User Volume 3 #9 / Commodore_Disk_User_Vol.3_9_1990_-.d64 / aw-text storage (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  5KB  |  144 lines

  1. 10 rem ********************************
  2. 15 rem * adventure writing on the c64 *
  3. 20 rem *                              *
  4. 25 rem *    written by jason finch    *
  5. 30 rem *         (c) cdu 1990         *
  6. 35 rem ********************************
  7. 40 :
  8. 45 poke53280,14:poke53281,6:print"[147][142]      please insert disk that can"
  9. 50 print"      be formatted (device eight)"
  10. 55 print,"[157][157]and then press 'return'":poke198,0
  11. 60 geta$:ifa$<>chr$(13)then60
  12. 65 print"[145]    are you sure about that??? [y/n]":poke198,0
  13. 70 geta$:ifa$="n"then45
  14. 75 ifa$<>"y"then70
  15. 80 :
  16. 85 rem ******************************
  17. 90 rem * display introductory info. *
  18. 95 rem ******************************
  19. 100 :
  20. 105 restore:print"[147]the following descriptions will now be"
  21. 110 print"saved, first to individual sectors which";
  22. 115 print"will be allocated as used and then as"
  23. 120 print"separate sequential files:"
  24. 125 fori=1to5:readd$(i):printd$(i)"":next
  25. 130 print"please wait: formatting the disk..."
  26. 135 :
  27. 140 rem *******************************
  28. 145 rem * format disk & check errors  *
  29. 150 rem *******************************
  30. 155 :
  31. 160 open15,8,15,"n0:aw-storage demo,aw":gosub655:close15:ifethen660
  32. 165 print"[147]ok. saving descriptions to sectors zero thro' four on track one:"
  33. 170 :
  34. 175 rem *******************************
  35. 180 rem * open channels to disk drive *
  36. 185 rem * and set write track and     *
  37. 190 rem * sector to one               *
  38. 195 rem *******************************
  39. 200 :
  40. 205 open15,8,15:open8,8,8,"#":tr=1:sr=0
  41. 210 :
  42. 215 rem *******************************
  43. 220 rem * send information to buffer  *
  44. 225 rem *******************************
  45. 230 :
  46. 235 fors=1to5:d$=d$(s):printd$"":print#15,"b-p 8 0"
  47. 240 forl=1tolen(d$):print#8,mid$(d$,l,1);:next:print#8,chr$(0);
  48. 245 print#15,"b-a 0";tr;sr:t(s)=tr:s(s)=sr:rem *** check block allocation
  49. 250 :
  50. 255 rem *******************************
  51. 260 rem * check error/block avail'bty *
  52. 265 rem *******************************
  53. 270 gosub655:ife=0then340
  54. 275 ife=66thentr=tr+1:sr=0:goto245
  55. 280 ife<>65thenclose8:close15:goto660:rem *** some other disk error
  56. 285 ifb=0thenclose8:close15:print"disk full":end:rem *** all blocks used
  57. 290 :
  58. 295 rem *******************************
  59. 300 rem * chosen block was already    *
  60. 305 rem * used. variables b/c from    *
  61. 310 rem * error checking hold next    *
  62. 315 rem * free sector location info.  *
  63. 320 rem * so set new tr/sr and re-try *
  64. 325 rem *******************************
  65. 330 :
  66. 335 tr=b:sr=c:goto245
  67. 340 print#15,"u2 8 0";tr;sr: rem *** write sector information
  68. 345 :
  69. 350 rem *******************************
  70. 355 rem * increment sector pointer    *
  71. 360 rem * then repeat for five loc'ns *
  72. 365 rem *******************************
  73. 370 :
  74. 375 sr=sr+1:next:close8:close15
  75. 380 :
  76. 385 rem *******************************
  77. 390 rem * all stored: do as seq.files *
  78. 395 rem *******************************
  79. 400 :
  80. 405 print"[147]ok. saving as separate sequential files called loc1,loc2,...,loc5:"
  81. 410 fors=1to5:d$=d$(s):printd$""
  82. 415 open2,8,1,"@0:loc"+mid$(str$(s),2)+",s,w":rem *** open sequential file
  83. 420 forl=1tolen(d$):print#2,mid$(d$,l,1);:next:rem *** send information
  84. 425 print#2,chr$(0);:close2:next
  85. 430 :
  86. 435 rem *******************************
  87. 440 rem * all stored: do as seq.files *
  88. 445 rem *******************************
  89. 450 :
  90. 455 print"[147]ok - all saved. now press a numeric"
  91. 460 print"key from one to five. that description"
  92. 465 print"will then be retrieved first from the"
  93. 470 print"individual sector and then from its     sequential file...":poke198,0
  94. 475 getk$:ifk$<"1"ork$>"5"then475
  95. 480 :
  96. 485 rem *******************************
  97. 490 rem * open channels for direct    *
  98. 495 rem * access commands and check   *
  99. 500 rem * for disk errors             *
  100. 505 rem *******************************
  101. 510 :
  102. 515 k=val(k$):open15,8,15:open8,8,8,"#":gosub655:ifethenclose8:close15:goto660
  103. 520 print#15,"u1 8 0";t(k);s(k):rem *** read track/sector to buffer
  104. 525 get#8,a$:ifa$=""then535
  105. 530 printa$;:goto525:rem *** loop back for more
  106. 535 close8:close15:print""
  107. 540 :
  108. 545 rem *******************************
  109. 550 rem * have read direct-now seq'tl *
  110. 555 rem *******************************
  111. 560 :
  112. 565 open2,8,0,"loc"+mid$(str$(k),2)+",s,r":rem *** open sequential file
  113. 570 get#2,a$:ifa$=""then615
  114. 575 printa$;:goto570:rem *** loop back for more
  115. 580 :
  116. 585 rem *******************************
  117. 590 rem * both forms have been        *
  118. 595 rem * recalled. wait for keypress *
  119. 600 rem * to return and repeat.       *
  120. 605 rem *******************************
  121. 610 :
  122. 615 close2:print:print"press any key for another..."
  123. 620 poke198,0:wait198,1:poke198,0:print"[147]for another description press a numeric"
  124. 625 goto460:rem *** go back and wait for another keypress
  125. 630 :
  126. 635 rem *******************************
  127. 640 rem * read disk error channel     *
  128. 645 rem *******************************
  129. 650 :
  130. 655 input#15,e,a$,b,c:return
  131. 660 print"[147]  disk error! [146]",,," "a$" @"b"[157],"c:print" press a key":poke198,0
  132. 665 wait198,1:poke198,0:goto45
  133. 670 :
  134. 675 rem *******************************
  135. 680 rem * data statements for simple  *
  136. 685 rem * description information     *
  137. 690 rem *******************************
  138. 695 :
  139. 700 data"you are standing on a stony path that   runs up the side of the hill."
  140. 705 data"inside the small cabin you notice a     chest on the eastern wall."
  141. 710 data"you are on a muddy path leading down to a fast flowing river."
  142. 715 data"the forest has become much more dense onthis side of the river."
  143. 720 data"you are standing in the middle of a     large clearing in the woods."
  144.